#pragma once

#include "Scanner.h"
#include "TokenManager.h"
#include "TableParsing.h"
//#include "CodeGenerator.h"
#include "CharacterTable.h"
#include "CheckMethodData.h"
#include "TempParseData.h"
#include "CharacterTableChecker.h"
#include "CodeGeneratorManager.h"
#include "CodeGenerator.h"

class CParser
{
public:
	CParser(CScanner & scanner, CCodeGeneratorManager & codeGeneratorManager);
	void Parse(bool isFirstParse);
private:
    void InitConvolutions();
    bool IsMember(std::string const & element) const;
    void RemoveElements(unsigned count);

    std::string R2();
    std::string R3();
    std::string R4();
    std::string R5();
    std::string R6();
    std::string R7();
    std::string R8();
    std::string R9();
    std::string R10();
    std::string R11();
    std::string R12();
    std::string R13();
    std::string R14();
    std::string R15();
    std::string R16();
    std::string R17();
    std::string R18();
    std::string R19();
    std::string R20();
    std::string R21();
    std::string R22();
    std::string R23();
    std::string R24();
    std::string R25();
    std::string R26();
    std::string R27();
    std::string R28();
    std::string R29();
    std::string R30();
    std::string R31();
    std::string R32();
    std::string R33();
    std::string R34();
    std::string R35();
    std::string R36();
    std::string R37();
    std::string R38();
    std::string R39();
    std::string R40();
    std::string R41();
    std::string R42();
    std::string R43();
    std::string R44();
    std::string R45();
    std::string R46();
    std::string R47();
    std::string R48();
    std::string R49();
    std::string R50();
    std::string R51();
    std::string R52();
    std::string R53();
    std::string R54();
    std::string R55();
    std::string R56();
    std::string R57();
    std::string R58();
    std::string R59();
    std::string R60();
    std::string R61();
    std::string R62();
    std::string R63();
    std::string R64();
	std::string R65();
    std::string R66();

	bool m_isFirstParse;

    CScanner & m_scanner;
	CTokenManager m_tokenManager;
	CCodeGeneratorManager & m_codeGeneratorManager;
	
    CTableParsing m_tableParsing;
	CCharacterTable m_characterTable;
	CCharacterTableChecker m_characterTableChecker;
    
	std::stack<CRow> m_rowsStack;
    std::map<std::string, std::string(CParser::*)()> m_convolutions;
};
